<template>
	<view>
		<!-- 购买记录 -->
		<view class="lb-list">
			<!-- <view class="lb-title">
				<image src="/static/icon/list.png" mode=""></image>
				<text>购买记录</text>
			</view> -->
			<view class="lb-table">
				<view class="lb-th">
					<text>会员类型</text>
					<text>金额</text>
					<text>购买时间</text>
					<text>有效期</text>
				</view>
				<u-empty v-if="listData.length < 1" mode="data" text="暂无购买记录" icon="/static/empty/data.png"> </u-empty>
				<view class="lb-td" v-for="(item,index) in listData" :key="index">
					<text>{{item.vip_name}}</text>
					<text>{{item.price}}</text>
					<text>{{item.pay_time}}</text>
					<text>{{item.expirer_time}}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getVipBuyApiList
	} from "@/api/apis/comm.js"
	export default {
		data() {
			return {
				page: 1,
				limit: 10,
				listData: [],
				isLoading: false
			}
		},
		onReachBottom() {
			//注意 这里是重要的一步，不满足条件下拉加载不能继续请求数据
			if (!this.isLoading) {
				this.getList();
			}

		},
		methods: {

			//列表
			getList() {
				uni.showLoading({
					title: "加载中",
					mask: true
				});
				this.isLoading = true;
				getVipBuyApiList({
					page: this.page,
					limit: this.limit,
				}).then(res => {
					uni.hideLoading();
					if (this.page == 1) {
						this.listData = res.data.data;
					} else {
						this.listData = this.listData.concat(res.data.data);
					}
					if (res.data.total > this.page * this.limit) {
						// console.log(res.data.length)
						//请求成功 节流阀 设置为false（没有走完函数不允许再次请求）
						this.isLoading = false;
						this.page++;
					}
				})
			},
		},
		onLoad() {
			this.getList();
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #FFFFFF;
	}

	.lb-list {
		background: rgba(255, 255, 255, 1);
		margin-top: 24rpx;
		width: 100%;
		padding: 32rpx;
		box-sizing: border-box;

		.lb-title {
			display: flex;
			flex-direction: row;
			align-items: center;
			padding: 24rpx 0;

			image {
				width: 40rpx;
				height: 40rpx;
			}

			text {
				font-size: $main-font-32;
				font-weight: bold;
				color: $main-font-color;
				padding-left: 18rpx;
			}
		}

		.lb-table {

			.lb-th {
				display: grid;
				// grid-template-columns: repeat(4, 1fr);
				grid-template-columns: 130rpx 100rpx auto auto;

				grid-gap: 2rpx 2rpx;
				padding-bottom: 24rpx;
				// border-bottom: 2rpx solid #F5F5F5;
				// margin-bottom: 24rpx;

				text {
					font-size: $main-font-24;
					font-weight: 400;
					color: $main-font-color-grey9;
				}
			}

			.lb-td {
				display: grid;
				// grid-template-columns: repeat(4, auto);
				grid-template-columns: 130rpx 100rpx auto auto;
				grid-gap: 2rpx 2rpx;
				padding: 24rpx 0;
				border-top: 2rpx solid #F5F5F5;
				// margin-bottom: 24rpx;

				text {
					font-size: 24rpx;
					font-weight: 400;
					color: $main-font-color;
					white-space: nowrap;

					&:nth-of-type(2) {
						width: 100rpx;

						&::before {
							content: '¥';
							margin-right: 2rpx;
						}
					}


				}
			}
		}

	}
</style>